import time


def read2list(filename):
    f = open(filename)
    s = [int(x) for x in f]
    return s


def bubble_sort(nums):
    for j in range(len(nums) - 1):
        for i in range(len(nums) - j - 1):
            if nums[i] > nums[i + 1]:
                nums[i], nums[i + 1] = nums[i + 1], nums[i]

    return nums


m1 = read2list("/home/student/Документы/Марафон/m1_sorted.txt")
m2 = read2list("/home/student/Документы/Марафон/m2_reverse.txt")
m3 = read2list("/home/student/Документы/Марафон/m3_shuffle.txt")

m1_start = time.time()
sort_m1 = bubble_sort(m1)
m1_finish = time.time()

m2_start = time.time()
sort_m2 = bubble_sort(m2)
m2_finish = time.time()

m3_start = time.time()
sort_m3 = bubble_sort(m3)
m3_finish = time.time()

print("m1_sorted", round((m1_finish - m1_start) * 1000), "millisec")
print("m2_reverse", round((m2_finish - m2_start) * 1000), "millisec")
print("m3_shuffle", round((m3_finish - m3_start) * 1000), "millisec")
